Namespace.Use("Base", function(ns) {
    var Timer = Polymorphic.Create(
        [Function, Number],
        function(callback, interval) {
            //
            //  Members.
            //
            var started = false;
            var instance = null;

            //
            //  Public methods.
            //
            this.AccessInterval = Polymorphic.Create(
                [],
                function() {
                    return interval;
                },
                [Number],
                function(value) {
                    //  Stop the timer.
                    if (started) {
                        clearInterval(instance);
                    }

                    //  Set the interval.
                    interval = value;

                    //  Restore the timer.
                    if (started) {
                        instance = setInterval(callback, interval);
                    }
                }
            );
            this.AccessEnabled = Polymorphic.Create(
                [],
                function() {
                    return started;
                },
                [Boolean],
                function(value) {
                    if (value == started) {
                        return;
                    }
                    if (started) {
                        clearInterval(instance);
                    } else {
                        instance = setInterval(callback, interval);
                    }
                    started = value;
                }
            );
        }
    );

    //  Export public APIs and classes.
    Namespace.Export(ns, "Timer", Timer);
});